package com.chainyoung.component_tmperson.ui.mvp.presenter;

import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.entity.OwnWalletDebit;
import com.chainyoung.component_tmperson.entity.WalletDebit;
import com.chainyoung.component_tmperson.entity.WalletRepayment;
import com.chainyoung.component_tmperson.ui.mvp.contract.OwnWalletDebitContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletApplyDebitContract;

import java.util.List;
import java.util.TreeMap;

import javax.inject.Inject;

public class OwnWalletDebitPresenter extends BasePresenter<OwnWalletDebitContract.Model, OwnWalletDebitContract.View> {

    @Inject
    public OwnWalletDebitPresenter(OwnWalletDebitContract.Model model, OwnWalletDebitContract.View rootView) {
        super(model, rootView);
    }


    public void getDebitCredit(TreeMap<String, Object> map) {

        addSubscribe(mModel.getDebitCredit(map)
                .compose(RxUtils.<String>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<String>(mView, false) {
                    @Override
                    public void onNext(String data) {
                        mView.onGetDebitCredit(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }


    public void getOwnWalletDebit(TreeMap<String, Object> map) {

        addSubscribe(mModel.getOwnWalletDebit(map)
                .compose(RxUtils.<OwnWalletDebit>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<OwnWalletDebit>(mView, false) {
                    @Override
                    public void onNext(OwnWalletDebit data) {
                        mView.onGetOwnWalletDebitSuccessed(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.onGetOwnWalletDebitFailed();
                        super.onError(e);
                    }
                }));
    }

}





